home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15330 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  56 lines

  1. Path: news.primenet.com!not-for-mail
  2. From: gbe@primenet.com (Gary Edstrom)
  3. Newsgroups: comp.os.ms-windows.programmer.win32,comp.lang.c++
  4. Subject: BUG REPORT: Microsoft Visual C++ 4.1
  5. Date: 4 Apr 1996 15:14:01 -0700
  6. Organization: Sequoia Software
  7. Sender: root@primenet.com
  8. Message-ID: <316445a3.428887193@news.primenet.com>
  9. X-Posted-By: ip238.lax.primenet.com
  10. X-Newsreader: Forte Agent .99d/32.182
  11.  
  12. /* BugDemo.cpp
  13.  
  14.    Here is a demonstration of a serious bug that I just found in Microsoft
  15.    Visual C++ Version 4.1. (The bug also exists in version 4.0).  When this
  16.    program is compiled with all of the default options in the debug mode, the
  17.    first of the two *= lines below fail to generate any code.  When compiled
  18.    in the release mode, everything is OK.  The problem also goes away in the
  19.    debug mode if you change the optimizations from "debug" to "compile for '
  20.    speed".  Note that the only difference between the first and second 
  21.    versions of the line is the use of a constant for the index rather than a 
  22.    variable.
  23.  
  24.   This sample was created as a console application.
  25. */
  26.  
  27. #include <stdio.h>
  28.  
  29. struct {
  30.     int a;
  31.     int b;
  32.     int c;
  33.     int d;
  34.     int e;
  35. } X[1] = { 1,2,3,4,5 };
  36.  
  37. int main( void)
  38. {
  39.  
  40.     int i = 0;
  41.  
  42.     X[i].a *= 2;  // <<<ERROR - No code generated in debug mode
  43.  
  44.     X[0].b *= 2; // This line works OK in either mode.
  45.  
  46.     printf( "a = %d, b = %d.\n", i, X[0].a, X[0].b );
  47.  
  48.     return 0;
  49. }
  50.  
  51. --
  52. Gary Edstrom <gbe@primenet.com> | Sequoia Software
  53. PO Box 9573                     | Programming & Technical Services
  54. Glendale CA 91226-0573          | PGP Key ID: 0x1A0D44BD
  55. PGP Fingerprint: 72 AA 4F 73 05 53 89 C6  8A EE F4 EE D1 C0 13 8D 
  56.